<?php

// defined('_JEXEC') or die;

/** 
 * @name: function render
 * @author : rock@onenix.net
 * @function: load template content with params
 *
 * @param	string 	$template	tên template
 * @param	string 	$params 	tham số truyền vào hàm
 * @param	bool	$print		in dữ liệu / trả về nội dung html
 *
 * @return: extension content
 */
function render($template,$params=null,$print=true) {
	if(empty($template)) {
		return;
	}
	if(is_object($params)) {
		$params = (array) $params;
	}
	if(is_array($params)) {
		extract($params, EXTR_SKIP);// Extract the variables to a local namespace
	}
	
	ob_start();                    	// Start output buffering
	{
		include $template;
		$contents = ob_get_contents();
	}
	ob_end_clean();               	// End buffering and discard
  
	if($print) {
		print $contents;
	} else {
		return $contents;			// Return the contents
	}
}
